<template>
    <view class="container">
        <tab-bar-two :tabs="items" nobg="nobg" @clickTab="clickTab" :tabIndex="tabIndex"></tab-bar-two>
        <view class="main">
            <swiper
                class="swiper product-main-list"
                :style="{ height: listHeight }"
                :current="tabIndex"
                @change="swiperChange">
                <swiper-item v-for="(swiperItem, swiperIndex) in items" :key="swiperIndex">
                    <deliver-list
                        v-if="loadOk"
                        :ref="'productList_' + swiperIndex"
                        :height="listHeight"
                        :state="swiperItem.state"
                        :orderId="orderId"></deliver-list>
                </swiper-item>
            </swiper>
        </view>
    </view>
</template>

<script>
import deliverList from "@/pages_supplier/components/supplyOrder/deliver-list.vue"
import tabBarTwo from "@/pages_supplier/components/common/tab-bar-two.vue"
import storage from "@/uni-sub-base/utils/storage.js"
import { getElementHeight } from "@/uni-sub-base/utils/elementUtil.js"
export default {
    components: {
        deliverList,
        tabBarTwo,
    },
    data() {
        return {
            optEmpty: {
                icon: "/static/img/empty.png", // 图标路径 (建议放入static目录, 如 /static/img/mescroll-empty.png )
                tip: "~ 暂无数据 ~", // 空提示
            },
            isloadding: false,
            tabIndex: 0,
            items: [
                {
                    state: "1",
                    title: "已发货",
                },
                {
                    state: "2",
                    title: "未发货",
                },
            ],
            listHeight: "", //list所需高度
            loadOk: false,
            searchKey: "",
            orderId: "",
        }
    },
    onLoad(e) {
        this.orderId = e.orderId
    },
    onShow() {},
    mounted() {
        this.getListHeight()
    },
    methods: {
        getListHeight(element) {
            //获取商品高度
            getElementHeight(this, ".main", (e) => {
                this.listHeight = e + "px"
                this.loadOk = true
            })
        },
        swiperChange(e) {
            let tabIndex = e.detail.current
            this.clickTab(tabIndex)
        },
        //tab切换
        clickTab(index) {
            if (this.tabIndex != index) {
                this.tabIndex = index
            }
        },
    },
}
</script>

<style lang="scss" scoped>
.container {
    display: flex;
    flex-direction: column;
}
</style>
